load Q7_example_data.mat
%load Q7_data.mat



% The laser range finder data visualized in a frame attached to the robot
% The robot frame has the robot's forward axis going to the right in the
% figure (i.e., the robot is facing towards the right in the plots).

skip = 2; % tends to run out of memory when plotting all (at least on some machines)
sk = 0;
ne_points = {};
for t=1:skip:length(scan_data)
    if(scan_data_valid{t})
        sk = sk+1;
        if(mod(sk,skip)==1)
            figure; hold on; xlabel('East'); ylabel('North');
			ne_points{t} = zeros(length(scan_angles),2);
            for scan_angle_idx = 1:length(scan_angles)
                if(scan_data{t}(scan_angle_idx) <= range)
                    scanpoint_north_coord = scan_data{t}(scan_angle_idx) * cos(scan_angles(scan_angle_idx)*pi/180);
                    scanpoint_east_coord = scan_data{t}(scan_angle_idx) * sin(scan_angles(scan_angle_idx)*pi/180);
                    plot(scanpoint_east_coord, scanpoint_north_coord, '.');
					
					ne_points{t}(scan_angle_idx,:) = [ scanpoint_north_coord scanpoint_east_coord]; 

                end
			end
			title(t);
        end
    end
end

% your code goes here